#include <bits/stdc++.h>
using namespace std;
struct MAN {
  int y;
  int m;
  int d;
};
MAN a[1000001];

bool guize(MAN x, MAN y) {
  return (x.y > y.y || x.y == y.y && x.m > y.m ||
          x.y == y.y && x.m == y.m && x.d > y.d);
}

int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    char _;
    cin >> a[i].y >> _ >> a[i].m >> _ >> a[i].d;
    sort(a + 1, a + n + 1, guize);
  }

  cout << a[n].y << "-";

  if (a[n].m < 10)
    cout << 0;
  cout << a[n].m << "-";

  if (a[n].d < 10)
    cout << 0;
  cout << a[n].d;
  
  return 0;
}